package com.chis.jmdatatimer.main;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.util.Bytes;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @Description 
 * @Company zwx
 * @author wlj
 * @version 2019年01月02日
 */
public class HbaseInsert {


    public static void main(String[] args) throws Exception{
        // 插入
        Configuration conf = HBaseConfiguration.create();
        HTable table = new HTable(conf, "ll:test");
        List<Put> list = new ArrayList<Put>();
        byte[] rowkey = Bytes.toBytes("3201020120");
        Put put = new Put(rowkey);
        put.add(Bytes.toBytes("info"), Bytes.toBytes("name"), Bytes.toBytes("test"));
        list.add(put);
        table.put(list);

//        Configuration conf = HBaseConfiguration.create();
//        HTable table = new HTable(conf, "jm:inoclation");
//        List<Put> list = new ArrayList<Put>();
//        byte[] rowkey = Bytes.toBytes("000253-52");
//        Put put = new Put(rowkey);
//        put.add(Bytes.toBytes("info"), Bytes.toBytes("name"), Bytes.toBytes("test"));
//        list.add(put);
//        table.put(list);
        //删除
//        Configuration conf = HBaseConfiguration.create();
//        Connection conn = ConnectionFactory.createConnection(conf);
//        TableName tname = TableName.valueOf("jm:inoclation");
//
//        Table table = conn.getTable(tname);
//        Delete del = new Delete(Bytes.toBytes("000253-52"));//rowkey
//        //del.addColumn(Bytes.toBytes("inof"), Bytes.toBytes("name"));
//        // del.addColumn(Bytes.toBytes("f1"), Bytes.toBytes("name"));
//        table.delete(del);
//        System.out.println("over");

    }



}
